package com.lh.mapper;

import com.lh.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("select * from user where username=#{username}")
    User findUserByName(String username);

    @Insert("insert into user(username,password,create_time,update_time) values(#{username},#{password},now(),now())")
    int registerUser(String username, String password);

    @Update("update user set username=#{username},nickname=#{nickname},email=#{email},update_time=#{updateTime} where id=#{id} ")
    int updateUser(User user);

    @Update("update user set user_pic=#{imageURL} ,update_time=now() where id=#{id}")
    int updateAvatar(String imageURL, int id);

    @Update("update user set password=#{password} where username=#{username} ")
    int updatePwd(String password, String username);
}
